<script setup>
import { ref } from 'vue'
import FileManage from './components/FileManage.vue'
import FileUpload from './components/FileUpload.vue'
import FilePreview from './components/FilePreview.vue'

const folderCreatedCast = ref(false)
const previewVisible = ref(false)
const previewFileInfo = ref({})

const handleUploadPath = (path) => {
  console.log('Upload path clicked:', path)
  // 可以在这里处理上传路径点击事件
}

const handleFolderCreatedEmit = () => {
  folderCreatedCast.value = false
}

const handleFilePreview = (fileInfo) => {
  previewFileInfo.value = fileInfo
  previewVisible.value = true
}
</script>

<template>
  <div class="app-container">
    <!-- <header class="app-header">
      <h1>云存储</h1>
    </header> -->
    <main class="app-main">
      <FileManage @file-preview="handleFilePreview" />
    </main>
    <FileUpload 
      :folder-created-cast="folderCreatedCast"
      @upload-path="handleUploadPath"
      @folder-created-emit="handleFolderCreatedEmit"
    />
    <FilePreview 
      v-model:visible="previewVisible" 
      :file-info="previewFileInfo"
    />
  </div>
</template>

<style>
/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #f0f2f5;
}

.app-container {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background-color: #fff;
  padding: 0 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.app-header h1 {
  font-size: 20px;
  font-weight: 500;
  color: #333;
  line-height: 60px;
}

.app-main {
  flex: 1;
  padding: 20px;
  overflow: hidden;
}
</style>
